//
//  HeroCollectionViewCell.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/19.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "HeroCollectionViewCell.h"

@implementation HeroCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame
{

    self = [super initWithFrame:frame];
    if (self) {
      
        [self createSubViews];
        
    }
    return self;

}


-(void)dealloc
{

    [_titleLabel release];
    [_locationLabel release];
    [_nameLabel release];
    [_myImageV release];
    [super dealloc];


}

-(void)createSubViews
{

    self.myImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width / 2, self.contentView.frame.size.width / 2)];
    self.myImageV.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myImageV];
    [_myImageV release];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myImageV.frame.size.width + 2, 0, self.contentView.frame.size.width - self.myImageV.frame.size.width - 2, 25)];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + 25, self.titleLabel.frame.size.width, self.titleLabel.frame.size.height)];
    self.nameLabel.backgroundColor = [UIColor clearColor];
   
    self.nameLabel.textColor = [UIColor lightGrayColor];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.nameLabel];
    [_nameLabel release];
    
    
    self.locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.nameLabel.frame.origin.y + 25, self.nameLabel.frame.size.width, self.nameLabel.frame.size.height)];
    
    self.locationLabel.backgroundColor = [UIColor clearColor];
    self.locationLabel.font = [UIFont systemFontOfSize:15];
    self.locationLabel.textColor = [UIColor purpleColor];
    [self.contentView addSubview:self.locationLabel];
    [_locationLabel release];
   

}


-(void)setModel:(HeroModel *)model
{

    if (_model != model) {
        
        [_model release];
        
        _model = [model retain];
    }


    self.titleLabel.text = self.model.title;
    self.titleLabel.lineBreakMode = NSLineBreakByCharWrapping;
    
    self.nameLabel.text = self.model.cnName;
    self.nameLabel.lineBreakMode = NSLineBreakByCharWrapping;
    
    self.locationLabel.text = self.model.location;
    self.locationLabel.lineBreakMode = NSLineBreakByCharWrapping;
    
    [self.myImageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",self.model.enName]] placeholderImage:[UIImage imageNamed:@"mangseng.png"]];
    

}














@end
